﻿//////////////////////////////////////////////////////////////////////////////////
//
// Project            : XNAsteroids
// Module             : XNAsteroidsGameObjects
// Description        : Collection of asteroids.
// 
// Repository         : $URL$
// Last changed by    : $LastChangedBy$
// Revision           : $LastChangedRevision$
// Last Changed       : $LastChangedDate$
// Author             : $Author$
//
// Id                 : $Id$
//
// Copyright          : (c) 2010 Torsten Bär
//
// Published under the MIT License. See license.txt or http://www.opensource.org/licenses/mit-license.php.
//
//////////////////////////////////////////////////////////////////////////////////

using System;
using System.Linq;
using Microsoft.Xna.Framework;

namespace XNAsteroids.GameObjects.SpaceObjects
{
   /// <summary>
   /// Collection of Asteroids.
   /// </summary>
   public class AsteroidCollection : SpaceObjectCollection<Asteroid>
   {
      /// <summary>
      /// Initializes a new instance of the <see cref="AsteroidCollection"/> class.
      /// </summary>
      /// <param name="game">The game.</param>
      public AsteroidCollection(Game game)
         : base(game)
      {}

      /// <summary>
      /// Called when the GameComponent needs to be updated. Override this method with component-specific update code.
      /// </summary>
      /// <param name="gameTime">Time elapsed since the last call to Update</param>
      public override void Update(GameTime gameTime)
      {
         base.Update(gameTime);
         innerList.Where(asteroid => ((Asteroid)asteroid).Radius <= 5).ToList().ForEach(item => innerList.Remove(item));
      }
   }
}